package com.cly.controller;

import com.cly.base.controller.BaseController;
import com.cly.dto.ResumeDto;
import com.cly.dto.ResumeInsertDto;
import com.cly.entity.Resume;
import com.cly.result.JsonRequest;
import com.cly.service.IResumeService;
import com.cly.vo.PostSubmitVo;
import com.cly.vo.ResumeOneVo;
import com.cly.vo.ResumeSubmitVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 简历控制类
 *
 * @author by 春风能解释
 * <p>
 * 2024/11/9
 */
@RestController
@RequestMapping("/resume")
@Tag(name = "简历控制类", description = "简历操作访问接口")
public class ResumeController extends BaseController<IResumeService, Resume> {

    /**
     * 查看一个简历
     *
     * @param id ID
     * @return JSON
     */
    @GetMapping
    @Operation(summary = "查看一个简历")
    public JsonRequest<ResumeOneVo> lookOneResume(
            @Parameter(description = "ID", required = true)
            @RequestParam Long id) {
        return baseService.lookOneResume(id);
    }


    /**
     * 查看用户的简历列表
     *
     * @param current 页码
     * @param size    页长
     * @param userId  用户ID
     * @return JSON
     */
    @GetMapping("/list")
    @Operation(summary = "查看用户的简历列表")
    public JsonRequest<List<Resume>> lookResumeList(
            @Parameter(description = "页码", required = true)
            @RequestParam Integer current,
            @Parameter(description = "页长", required = true)
            @RequestParam Integer size,
            @Parameter(description = "ID", required = true)
            @RequestParam Long userId) {
        return baseService.lookResumeList(current, size, userId);
    }

    /**
     * 查看已投递的岗位列表
     *
     * @param userId  用户ID
     * @param current 页码
     * @param size    页长
     * @return JSON
     */
    @GetMapping("/post")
    @Operation(summary = "查看已投递的岗位列表")
    public JsonRequest<List<PostSubmitVo>> lookPostList(
            @Parameter(description = "页码", required = true)
            @RequestParam Integer current,
            @Parameter(description = "页长", required = true)
            @RequestParam Integer size,
            @Parameter(description = "用户ID", required = true)
            @RequestParam Long userId) {
        return baseService.lookPostList(current, size, userId);
    }

    /**
     * 查看已投递的简历列表
     *
     * @param resumeDto 条件
     * @param current   页码
     * @param size      页长
     * @return JSON
     */
    @GetMapping("/resume")
    @Operation(summary = "查看已投递的简历列表")
    public JsonRequest<List<ResumeSubmitVo>> lookResume(
            @Parameter(description = "页码", required = true)
            @RequestParam Integer current,
            @Parameter(description = "页长", required = true)
            @RequestParam Integer size,
            @Parameter(description = "岗位ID", required = true)
            ResumeDto resumeDto) {
        return baseService.lookResume(current, size, resumeDto);
    }

    /**
     * 修改简历提交状态
     *
     * @param resumeDto 投递信息
     * @return JSON
     */
    @PutMapping("/updateSubmit")
    @Operation(summary = "修改简历提交状态")
    public JsonRequest<Boolean> updateSubmitResume(
            @Parameter(description = "投递信息", required = true)
            @RequestBody ResumeDto resumeDto) {
        return baseService.updateSubmitResume(resumeDto);
    }

    /**
     * 提交简历
     *
     * @param resumeId 简历ID
     * @param postId   岗位ID
     * @return JSON
     */
    @PostMapping("/submit")
    @Operation(summary = "提交简历")
    public JsonRequest<Boolean> submitResume(
            @Parameter(description = "简历ID", required = true)
            @RequestParam Long resumeId,
            @Parameter(description = "岗位ID", required = true)
            @RequestParam Long postId) {
        return baseService.submitResume(resumeId, postId);
    }

    /**
     * 新增一个简历
     *
     * @param reservationInsertDto 简历实体
     * @return JSON
     */
    @PostMapping
    @Operation(summary = "新增一个简历")
    public JsonRequest<Boolean> addOneResume(
            @Parameter(description = "简历实体", required = true)
            @RequestBody ResumeInsertDto reservationInsertDto) {
        return baseService.addOneResume(reservationInsertDto);
    }

    /**
     * 删除一个简历
     *
     * @param id ID
     * @return JSON
     */
    @DeleteMapping
    @Operation(summary = "删除一个简历")
    public JsonRequest<Integer> deleteResume(
            @Parameter(description = "ID", required = true)
            @RequestParam Long id) {
        return baseService.deleteResume(id);
    }

    /**
     * 修改一个简历
     *
     * @param reservationInsertDto 简历实体
     * @return JSON
     */
    @PutMapping
    @Operation(summary = "修改一个简历")
    public JsonRequest<Boolean> updateResume(
            @Parameter(description = "简历实体", required = true)
            @RequestBody ResumeInsertDto reservationInsertDto) {
        return baseService.updateResume(reservationInsertDto);
    }

}
